# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=yasat
pkgver=848
pkgrel=2
groups=('blackarch' 'blackarch-scanner' 'blackarch-recon'
        'blackarch-fingerprint')
pkgdesc='Yet Another Stupid Audit Tool.'
arch=('any')
url='https://yasat.sourceforge.net/'
license=('GPL3')
source=("https://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz"
        "$pkgname.conf")
sha512sums=('0bc0e8e1068bee05242b5c7a7cdc8ca976503f696aef2889870ef872546021d0956489cf8d5b304a36be412cf8e5c8cbf4be5aa1cce5df008c5185188e5a99dc'
            '5e5403dad904128782216431c8c55a59fac02a8bb0b4df92649e1dc89e679a0648cbaaf593cee91fbdb60dbfcd62ecfa020d65894b4ad45d7e541b40cf854d11')

prepare() {
  cd $pkgname

  # To remove when https://github.com/montjoie/yasat/pull/1 is merged
  sed -i "s#TEMPYASATDIR=\"\`echo ~/.yasat/#TEMPYASATDIR=\"\`echo ~/.yasat#g" common
  sed -i "s#YASAT_HOMEDIR=\"\`echo ~/.yasat/#YASAT_HOMEDIR=\"\`echo ~/.yasat#g" yasat
  sed -i "s#{YASAT_ROOT}/yasat.advices#{YASAT_HOMEDIR}/yasat.advices#g" yasat
  sed -i "s#HOME/.yasat/#HOME/.yasat#g" yasat
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a plugins "$pkgdir/usr/share/$pkgname/"

  chmod 755 "$pkgdir/usr/share/$pkgname/plugins"
  chmod 644 "$pkgdir"/usr/share/$pkgname/plugins/*
  chmod 755 "$pkgdir"/usr/share/$pkgname/plugins/*.test

  install -Dm 755 $pkgname "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 "$srcdir"/yasat.conf "$pkgdir/etc/$pkgname/$pkgname.conf"
  install -m 644 -t "$pkgdir/usr/share/$pkgname" yasat.css common osdetection
  install -Dm 644 "man/$pkgname.8" "$pkgdir/usr/share/man/man8/$pkgname.8"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" BUGS CHANGELOG README
  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname" COPYRIGHT LICENCE

  touch "$pkgdir/usr/share/$pkgname/$pkgname.advices"
  chmod 644 "$pkgdir/usr/share/$pkgname/$pkgname.advices"
}

